/*
 * $Id: XLICell.h,v 1.1 2006-02-09 07:46:37 bacon Exp $
 */

#ifndef _XPP_XLI_XLICELL_CLASS_
#define _XPP_XLI_XLICELL_CLASS_

#include <xpp/xli/XLIKey.h>
#include <xpp/xli/XLIVal.h>

namespace xpp
{

	namespace xli
	{
		
		class XLICell
		{
		public:
			friend class XLI;
		
			XLICell (XLIKey* k = XP_NULL, XLIVal* v = XP_NULL) :
				_key(k), _val(v), _cdr(XP_NULL)
			{
			}

			~XLICell () 
			{
				if (_key != XP_NULL) delete _key;
				if (_val != XP_NULL) delete _val;
				//if (_cdr != XP_NULL) delete _cdr;	
			}
		
			XLIKey* key () 
			{
				return _key;
			}

			const XLIKey* key () const
			{
				return _key;
			}

			XLIVal* val () 
			{
				return _val;
			}

			const XLIVal* val () const
			{
				return _val;
			}

			XLICell* cdr () 
			{
				return _cdr;
			}

			const XLICell* cdr () const
			{
				return _cdr;
			}
		
			void setKey (XLIKey* k) 
			{
				//xp_assert (_key == XP_NULL);
				_key = k;
			}
			void setVal (XLIVal* v) 
			{
				//xp_assert (_val == XP_NULL);
				_val = v;
			}
			void setCdr (XLICell* c) 
			{
				//xp_assert (_cdr == XP_NULL);
				_cdr = c;
			}
		
			void set (XLIKey* k, XLIVal* v, XLICell* c = XP_NULL) 
			{
				//xp_assert (_key == XP_NULL);
				//xp_assert (_val == XP_NULL);
				_key = k;
				_val = v;
				_cdr = c;
			}
		
			/*
			bool isStr () 
			{
				return false;
			}

			bool isList () 
			{
				return false;
			}
			*/
		
		protected:
			XLIKey*  _key;
			XLIVal*  _val;
			XLICell* _cdr;
		};
		
	}
}
#endif
